package day0725API;

import java.io.*;

//和FileInputStream相比较可以一次读取一个汉字(FileInputStream一次只能读一个字节)
//注： 用BufferedInputStream封装FileInputStream也一次只能读一个字节(不能一次读一个汉字)
public class Test9 {

    public static void main(String[] args) {

        /*try(FileInputStream fis=new FileInputStream("src/day0725API/Test1.java");
            InputStreamReader  isr=new InputStreamReader(fis)){*/

        try(FileInputStream fis=new FileInputStream("src/day0725API/Test1.java");
            BufferedInputStream  bis=new BufferedInputStream(fis);
            InputStreamReader  isr=new InputStreamReader(bis);

            FileOutputStream fos=new FileOutputStream("src/day0725API/Test1_2.txt");
            BufferedOutputStream  bos=new BufferedOutputStream(fos);
            OutputStreamWriter  osr=new OutputStreamWriter(bos);){
            int data=-1;
            while(  (data=isr.read())!=-1){
                osr.write(data);
            }

        }catch (IOException e){
            e.printStackTrace();
        }finally {
            System.out.println("完毕");
        }
    }

}
